export default {
  init: function() {
    //一期地图密钥：
    // const appkey = "39602809e8d530dba87b9dab21f08319";
    // const appsecret = "e0f916e806ff3f97b7d1eca59f1962fa";
    //二期地图密钥：
    const appkey = 'fefe3a1d8cf4399cb4cad19d789d156d'
    const appsecret = '9bf4a465dc0f37129f00cd59cd681ce8'
    const BMap_URL = 'https://map.sgcc.com.cn/maps?v=3.0.0'
 
    return new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.setAttribute('type', 'text/javascript')
      script.async = false
      script.setAttribute('src', BMap_URL)
      script.onload = function() {
        // 申请的key和sn
        SGMap.tokenTask.login(appkey, appsecret).then(function() {
          resolve()
        })
      }
      document.getElementsByTagName('head')[0].appendChild(script)
    })
  },
}
